﻿using System.ComponentModel.Composition;
using SS.Net.AppGen.Utils;
using SS.Common.DBBuilder.DBDataStructure;
using System.IO;
using SS.Net.AppGen.Generators;

namespace SS.Net.AppGen.WebGenerators.WebViewGenerator
{
    /// <summary>
    /// The generator is responsible for generating admin view class
    /// </summary>
    [Export(typeof(AdminViewGenerator))]
    public sealed class AdminViewGenerator : BaseGenerator, IWebComponentsGenerator
    {
        #region Methods

        /// <summary>
        /// The method is responsible for generating all partials
        /// </summary>
        /// <param name="db">Data source for generating</param>
        public void Generate(DataBase db)
        {
            foreach (Table tbl in db.Tables)
            {
                // Skips a Table if it is existent in Skip array
                if (!this.IsItemExistent(BaseConsts.SkipTables, tbl.Name))
                {
                    var Generator = IoC.Get<PartialViewGenerator>();

                    // Start to generate contents
                    if (Generator != null)
                    {
                        //Generator.DirPath = this.DirPath;
                        Generator.GenerateContents(tbl);
                    }
                }
            }
        }

        #endregion
    }
}
